package com.lc.advertising.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.lc.advertising.R;
import com.lc.advertising.app.AppActivity;
import com.lc.advertising.base.BaseDialog;
import com.lc.advertising.dialog.MessageDialog;
import com.lc.advertising.manager.ActivityManager;

import butterknife.ButterKnife;
import butterknife.OnClick;

public class SettingActivity extends AppActivity {
    @Override
    protected int getLayoutId() {
        return R.layout.activity_setting;
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void initData() {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @OnClick({R.id.sb_banben, R.id.sb_xieyi, R.id.sb_guanyu, R.id.sb_xiugai, R.id.sb_kefu, R.id.sb_out})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.sb_banben:
                startActivity(new Intent(this,DanyeActivity.class).putExtra("id","30").putExtra("title","版本信息"));
                break;
            case R.id.sb_xieyi:
                startActivity(new Intent(this,DanyeActivity.class).putExtra("id","32").putExtra("title","注册协议"));
                break;
            case R.id.sb_guanyu:
                startActivity(new Intent(this,DanyeActivity.class).putExtra("id","31").putExtra("title","关于我们"));
                break;
            case R.id.sb_xiugai:
             startActivity(EditPwdActivity.class);
                break;
            case R.id.sb_kefu:
                startActivity(new Intent(this,DanyeActivity.class).putExtra("id","33").putExtra("title","联系客服"));
                break;
            case R.id.sb_out:
                new MessageDialog.Builder(getActivity())
                        // 标题可以不用填写
                        .setTitle("退出登录")
                        // 内容必须要填写
                        .setMessage("是否退出登录")
                        // 确定按钮文本
                        .setConfirm(getString(R.string.common_confirm))
                        // 设置 null 表示不显示取消按钮
                        .setCancel(getString(R.string.common_cancel))
                        // 设置点击按钮后不关闭对话框
                        //.setAutoDismiss(false)
                        .setListener(new MessageDialog.OnListener() {

                            @Override
                            public void onConfirm(BaseDialog dialog) {
                                startActivity(LoginActivity.class);
                                // 进行内存优化，销毁除登录页之外的所有界面
                                ActivityManager.getInstance().finishAllActivities(LoginActivity.class);
                            }

                            @Override
                            public void onCancel(BaseDialog dialog) {
                           dialog.dismiss();
                            }
                        })
                        .show();
                break;
        }
    }
}
